From: Matthias Clasen Date: Fri, 31 Dec 2021 14:49:40 +0000 (-0500) Subject: fontchooserwidget: Avoid a crash X-Git-Tag: archive/raspbian/4.6.5+ds-1+rpi1~1^2~61^2^2~135^2~2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=e12ef76de532d4cf652fe50383bc5bb378866295;p=gtk4.git fontchooserwidget: Avoid a crash languages may be NULL, we need to be more careful here. --- diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c index e16de437c4..27608eb16f 100644 --- a/gtk/gtkfontchooserwidget.c +++ b/gtk/gtkfontchooserwidget.c @@ -603,19 +603,20 @@ maybe_update_preview_text (GtkFontChooserWidget *self, /* Otherwise, we make a list of representative languages */ langs = g_hash_table_new (NULL, NULL); - for (i = 0; languages[i]; i++) - { - const PangoScript *scripts; - int num, j; + if (languages) + for (i = 0; languages[i]; i++) + { + const PangoScript *scripts; + int num, j; - scripts = pango_language_get_scripts (languages[i], &num); - for (j = 0; j < num; j++) - { - lang = pango_script_get_sample_language (scripts[j]); - if (lang) - g_hash_table_add (langs, lang); - } - } + scripts = pango_language_get_scripts (languages[i], &num); + for (j = 0; j < num; j++) + { + lang = pango_script_get_sample_language (scripts[j]); + if (lang) + g_hash_table_add (langs, lang); + } + } /* ... and compare it to the users default and preferred languages */ if (g_hash_table_contains (langs, default_lang) ||